<template>
    <div class="tag">
        <div class="button-dc" @click="catClick('全部')">全部</div>
        <div v-for="tag in tags" :key="tag.id" class="button-dc" @click="catClick(tag.name)">{{ tag.name }}</div>
    </div>
</template>

<script setup lang="ts">
import { onMounted, ref } from "vue";
import { GetCateGorTags } from "@/api/api.ts";
import type {tags} from '@/models/categorplaylist'

const emit = defineEmits<{
    (e: 'catChange', cat: string): void,
}>()

const catClick = (cat: string) => {
    emit('catChange', cat)
}

const tags = ref<tags>()

onMounted(async () => {
    await GetCateGorTags().then(res => {
        tags.value = res.data.tags
    })
})
</script>

<style lang="less">
.tag {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    @media (min-width: 1440px) {
        grid-template-columns: repeat(12, minmax(0, 1fr));
        gap: 0.625rem;
    }

    .button-dc {
        display: flex;
        height: 2rem;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        border-radius: 0.25rem;
        --tw-bg-opacity: 1;
        background-color: rgb(230 230 230 / var(--tw-bg-opacity));
        font-size: 0.875rem;
        line-height: 1.25rem;
        transition-property: all;
        transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
        transition-duration: 150ms;
    }
}
.button-dc:hover {
    color: #34D399;
}
</style>
